#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using System;
using UnityEngine;
using UnityEngine.Networking;

public static class NeatlyConfig
{
    //AssetBundle缓存时间
    public const int TIME_BUNDLE_CACHE = 10;
    //是否启用bundle模式
    public static bool AssetBundleEnable = false;
    //音效数量
    public const int SOUND_SOURCE_COUNT = 10;
    //默认音效
    public const string NAME_DEFAULT_SOUND = "click";
    //manifest清单文件名
    public const string NAME_MANIFEST = "bundle";
    //AssetBundleMap名
    public const string NAME_ASSET_BUNDLE_MAP = "assetbundlemap";
    //assets目录
    public const string ASSETS_ROOT = "assets";
    //tp图集目录
    public const string PATH_ATLAS_TP = "data/ui/atlas_tp/";
    //UIPanel目录
    public const string PATH_UI_PANEL = "data/ui/panel/";
    //tp Bundle图集目录
    public const string PATH_BUNDLE_ATLAS_TP = "data_ui_atlas_tp_";
    //padding边数据
    public const string NAME_ATLAS_CONFIG = "atlasconfig";
    //padding边数据
    public const string PATH_FILE_ATLAS_CONFIG = "data/ui/atlasconfig.asset";
    //padding边数据
    public const string PATH_BUNDLE_ATLAS_CONFIG = "data_ui_atlasconfig";
    //emoji目录名
    public const string NAME_EMOJI_LIBRARY = "emoji";
    //音效资源后缀
    public const string SUFFIX_SOUND = ".ogg";
    //音乐资源后缀
    public const string SUFFIX_MUSIC = ".mp3";
    //视频资源后缀
    public const string SUFFIX_VIDEO = ".mp4";
    //场景 包名
    public const string SCENE_PACKAGE = "scene";
    //语音 包名
    public const string VOICE_PACKAGE = "voice";
    //音效 包名
    public const string SOUND_PACKAGE = "sound";
    //音乐 包名
    public const string MUSIC_PACKAGE = "music";
    //视频 包名
    public const string VIDEO_PACKAGE = "video";
    //字体 包名
    public const string FONT_PACKAGE = "font";
    //是否64位程序
    public static bool Is64Bit => IntPtr.Size == 8;
    //lua x86包
    public const string LUA_PACKAGE_32 = "lua32";
    //lua x64包
    public const string LUA_PACKAGE_64 = "lua64";
    //lua 包名
    public static string LUA_PACKAGE => Is64Bit ? LUA_PACKAGE_64 : LUA_PACKAGE_32;
    //bundle 包名
    public const string BUNDLE_PACKAGE = "bundle";
    //bundle 偏移
    public const int BUNDLE_OFFSET = 7;
    //文件manifest
    public static readonly string FILE_HASH = "file_hash";
    public static readonly string FILE_TXT_VERSION = "version.txt";
    //包路径
#if !UNITY_EDITOR && UNITY_ANDROID
    public static readonly string PATH_PACKAGE = $"{Application.dataPath}!assets";
#else
    public static readonly string PATH_PACKAGE = Application.streamingAssetsPath;
#endif
    public static readonly string PATH_PACKAGE_BUNDLE = $"{PATH_PACKAGE}/{BUNDLE_PACKAGE}";
    public static readonly string PATH_PACKAGE_LUA = $"{PATH_PACKAGE}/{LUA_PACKAGE}";
    //更新包路径
    public static readonly string PATH_UPDATE = $"{Application.persistentDataPath}/update";
    public static readonly string PATH_UPDATE_BUNDLE = $"{PATH_UPDATE}/{BUNDLE_PACKAGE}";
    public static readonly string PATH_UPDATE_LUA = $"{PATH_UPDATE}/{LUA_PACKAGE}";
    public const string FOLDER_I18N = "i18n";
    public static readonly string PATH_UPDATE_I18N = $"{PATH_UPDATE}/{FOLDER_I18N}";

    //路径表
    public static readonly string[] ASSETS_PATHS = {PATH_UPDATE_BUNDLE};
    //下载路径
    public static readonly string PATH_DOWNLOAD = $"{Application.persistentDataPath}/download";
    public static readonly string PATH_DOWNLOAD_LUA = $"{Application.persistentDataPath}/download/lua";
    public static readonly string PATH_DOWNLOAD_BUNDLE = $"{Application.persistentDataPath}/download/bundle";
    public static readonly string PATH_DOWNLOAD_TEXTURE = $"{Application.persistentDataPath}/download/texture";
    // 安卓临时目录
    public static readonly string PATH_ANDROID_PACKAGE_TEMP = $"{Application.persistentDataPath}/temp_res";
    public static readonly string PATH_ANDROID_PACKAGE_TEMP_BUNDLE = $"{PATH_ANDROID_PACKAGE_TEMP}/{BUNDLE_PACKAGE}";
    public static readonly string PATH_ANDROID_PACKAGE_TEMP_LUA = $"{PATH_ANDROID_PACKAGE_TEMP}/{LUA_PACKAGE}";
    //请求超时时间
    public static int REQUEST_TIMEOUT = 5000;
    //CanvasWidth
    public const int CANVAS_WIDTH = 640;
    //CanvasWidth
    public static float CANVAS_HEIGHT = 1136;
    public static float CANVAS_PADDING_TOP = 0;
    public static float CANVAS_PADDING_BOTTOM = 0;
    //CanvasHeight
    public const int CANVAS_MAX_HEIGHT = 1280;
    //屏幕比例
    public static float SCREEN_RATIO => Screen.height * 1.0f / Screen.width;
    //CPU核心数
    public static readonly int PROCESSOR_COUNT = SystemInfo.processorCount;
    //默认线程数
    public static readonly int NORMAL_THREAD_COUNT = PROCESSOR_COUNT * 2;
    //设备型号
    public static readonly string DEVICE_MODEL = SystemInfo.deviceModel;
    //系统版本
    public static readonly string SYSTEM_VERSION = SystemInfo.operatingSystem;
    //显卡设备
    public static readonly string GRAPHICS_DEVICE_NAME = SystemInfo.graphicsDeviceName;
    //设备ID
    public static readonly string DEVICE_ID = SystemInfo.deviceUniqueIdentifier;
    //CDN domain
    public static string WEBGL_CDN_DOMAIN;

    public static string GetFileHashName(int patch)
    {
        return $"{FILE_HASH}_{patch}";
    }
#if UNITY_STANDALONE_WIN
    public const string NAME_SYSTEM_PLATFORM = "win64";
#elif UNITY_ANDROID
    public const string NAME_SYSTEM_PLATFORM = "android";
#elif UNITY_IOS
    public const string NAME_SYSTEM_PLATFORM = "ios";
#elif UNITY_WEBGL
    public const string NAME_SYSTEM_PLATFORM = "webgl";
#else
    public const string NAME_SYSTEM_PLATFORM = "win64";
#endif
    //web请求AssetBundle
    public static Func<string, UnityWebRequest> WebRequestAssetBundleAction;
    public static Func<DownloadHandler, AssetBundle> DownloadGetAssetBundleAction;
    public static Action<AssetBundle, bool> AssetBundleUnloadAction;
}